package com.mx.zb.mng.utils.context;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.util.StringUtils;

public class ContextInfo {
	
	private String operatorId;
	private String agentId;
	
	private int draw;
	private int start;
	private int length;
	
	private String orderColumn;
	private String orderDir;
	
	private String search;
	
	public ContextInfo(HttpServletRequest request) {
		HttpSession session = request.getSession();
		operatorId = (String)session.getAttribute("operatorId");
		
		agentId = (String)session.getAttribute("agentId");
		String startStr=request.getParameter("start");		
		String lengthStr=request.getParameter("length");
		String drawStr=request.getParameter("draw");
		if(StringUtils.hasText(lengthStr) && StringUtils.hasText(startStr)) {
			start = Integer.parseInt(startStr);
			length = Integer.parseInt(lengthStr);
			if(StringUtils.hasText(drawStr)) {
				draw = Integer.parseInt(drawStr);
			}
			
			String columnNumStr = request.getParameter("order[0][column]");
			orderDir = request.getParameter("order[0][dir]");
			if(StringUtils.hasText(orderDir) && StringUtils.hasText(columnNumStr)) {
				orderColumn = request.getParameter("columns["+ columnNumStr.trim() +"][data]");				
			}
			
			search = request.getParameter("search[value]");
		}
	}

	public String getOperatorId() {
		return operatorId;
	}

	public String getAgentId() {
		return agentId;
	}

	public int getStart() {
		return start;
	}

	public int getLength() {
		return length;
	}

	public int getDraw() {
		return draw;
	}

	public void setDraw(int draw) {
		this.draw = draw;
	}

	

	public String getOrderColumn() {
		return orderColumn;
	}

	public void setOrderColumn(String orderColumn) {
		this.orderColumn = orderColumn;
	}

	public String getOrderDir() {
		return orderDir;
	}

	public void setOrderDir(String orderDir) {
		this.orderDir = orderDir;
	}

	public String getSearch() {
		return search;
	}
	
	
	

}
